package com.xiaoqian.partyembassy;

import android.content.Context;
import android.util.Log;

import com.xiaoqian.partyembassy.constant.UrlConfig;
import com.xiaoqian.partyembassy.tools.okhttp.CallBackUtil;
import com.xiaoqian.partyembassy.tools.okhttp.OkhttpUtil;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import okhttp3.Call;
import okhttp3.Response;

import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.HashMap;
import java.util.Map;

import static org.junit.Assert.*;

/**
 * Instrumented test, which will execute on an Android device.
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
    @Test
    public void useAppContext() {
        // Context of the app under test.
        Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
        assertEquals("com.xiaoqian.partyembassy", appContext.getPackageName());
    }
    @Test
    public void getTest(){
                Map<String,String> paramsMap = new HashMap<>();
        paramsMap.put("indoor-uid","0");
        paramsMap.put("indoor-token","1234567890123456");
        OkhttpUtil.okHttpPost(UrlConfig.getShowroom, paramsMap, new CallBackUtil() {
            @Override
            public Object onParseResponse(Call call, Response response) {
                return null;
            }

            @Override
            public void onFailure(Call call, Exception e) {
                Log.e("onFailure","_"+e.toString());
            }

            @Override
            public void onResponse(Object response) {
                String json = (String) response;
                Log.e("onResponse","_"+json);
            }
        });
    }
}